package io.renren.modules.gengyun.utils;

import io.renren.modules.gengyun.service.AirConditionHourlyService;
import io.renren.modules.gengyun.service.SoilConditionHourlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class Tools {

    @Autowired
    AirConditionHourlyService airConditionHourlyService;

    @Autowired
    SoilConditionHourlyService soilConditionHourlyService;

    public List<Integer> cropRotationCompare(String cropRotationId,
                                             String crop,
                                             String indicator,
                                             Long beginTime,
                                             Long endTime) {
        /**
         * 空气表
         */
        if ("air".equals(crop)) {
            if ("humidity".equals(indicator)) {
                return airConditionHourlyService.getHumidityByCropRotationId(cropRotationId, beginTime, endTime);
            } else if ("temperature".equals(indicator)) {
                return airConditionHourlyService.getTemperatureByCropRotationId(cropRotationId, beginTime, endTime);
            } else if ("precipitation".equals(indicator)) {
                return airConditionHourlyService.getPrecipitationByCropRotationId(cropRotationId, beginTime, endTime);
            }

        /**
         * 土壤表
         */
        } else if ("soil".equals(crop)) {
            if ("humidity".equals(indicator)) {
                return soilConditionHourlyService.getHumidityByCropRotationId(cropRotationId, beginTime, endTime);
            } else if ("temperature".equals(indicator)) {
                return soilConditionHourlyService.getTemperatureByCropRotationId(cropRotationId, beginTime, endTime);
            }
        }
        return null;
    }
}
